package com.agricultural.emergency;

import com.agricultural.equipment.AgriculturalEquipment;

public class LowFuelHandler implements EmergencyHandler {
    private EmergencyHandler nextHandler;
    private double[] fuelStationPosition = {50, 50};

    public LowFuelHandler(EmergencyHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    @Override
    public void handleEmergency(AgriculturalEquipment equipment, String emergencyType) {
        if ("low_fuel".equalsIgnoreCase(emergencyType)) {
            System.out.println("处理低油量紧急情况: " + equipment.getEquipmentId());
            equipment.stop();
            System.out.println(equipment.getEquipmentId() + " 前往加油站: [" + 
                    fuelStationPosition[0] + ", " + fuelStationPosition[1] + "]");
            equipment.moveTo(fuelStationPosition);
            equipment.refuel();
        } else if (nextHandler != null) {
            nextHandler.handleEmergency(equipment, emergencyType);
        }
    }
}    